package tt.langchain4j.model;

import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.chat.StreamingChatLanguageModel;
import dev.langchain4j.model.ollama.OllamaChatModel;
import dev.langchain4j.model.ollama.OllamaStreamingChatModel;
import tt.langchain4j.Constants;
import tt.langchain4j.core.BufferSupplier;

import java.time.Duration;
import java.util.function.Supplier;

public enum ChatLanguageModels {

    LLAMA_32_VISION_11B("llama3.2-vision:11b") ,
    LLAVA("llava") ,
    DEEP_SEEK_R1_7B("deepseek-r1:7B") ,



    ;

    public static final ChatLanguageModels DEFAULT = DEEP_SEEK_R1_7B;

    final BufferSupplier<ChatLanguageModel> model;

    final BufferSupplier<StreamingChatLanguageModel> streamModel;

    ChatLanguageModels( String modelName ) {
        this(
                ()->OllamaChatModel.builder()
                        .baseUrl(Constants.OLLAMA_URL)
                        .modelName(modelName)
                        .timeout(Duration.ofMinutes(5))
                        .build()
                ,
                ()->OllamaStreamingChatModel.builder()
                        .baseUrl(Constants.OLLAMA_URL)
                        .modelName(modelName)
                        .timeout(Duration.ofMinutes(5))
                        .build()
        );
    }

    ChatLanguageModels(Supplier<ChatLanguageModel> model , Supplier<StreamingChatLanguageModel> streamModel ) {
        this.model = new BufferSupplier<>(model);
        this.streamModel = new BufferSupplier<>(streamModel);
    }

    public ChatLanguageModel model() {
        return model.get();
    }

    public StreamingChatLanguageModel streamModel() {
        return streamModel.get();
    }
}
